export function useFormValidation(formData) {
  const registerRules = {
    username: [
      { required: true, message: '请输入用户名', trigger: 'blur' },
      { min: 4, max: 16, message: '长度在4到16个字符', trigger: 'blur' }
    ],
    password: [
      { required: true, message: '请输入密码', trigger: 'blur' },
      { min: 6, max: 20, message: '长度在6到20个字符', trigger: 'blur' }
    ],
    confirmPassword: [
      { 
        validator: (rule, value, callback) => {
          if (value !== formData.password) {
            callback(new Error('两次输入密码不一致'))
          } else {
            callback()
          }
        }, 
        trigger: 'blur' 
      }
    ],
    email: [
      { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' }
    ],
    role: [
      { required: true, message: '请选择身份', trigger: 'change' }
    ],
    institution: [
      { required: true, message: '请输入机构名称', trigger: 'blur' }
    ]
  }

  return {
    registerRules
  }
}
